home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-16 | 1.7 KB | 58 lines | [TEXT/CWIE] |
- // ===========================================================================
- // • CBalloonKeyAttachment CBalloonKeyAttachment •
- // ===========================================================================
- // Allows the "Help" key to toggle balloon help off and on.
- //
- // Last update: Paul Robichaux <paul@ljl.com>, 5/16/96
- //
- // ©1996 Paul Robichaux. All rights reserved. Free for use in noncommercial or
- // shareware products; contact author for other uses. As a courtesy, please send
- // me bug reports, updates, or improvement suggestions if you have 'em.
- //
- // For use only with msg_KeyPress. You could add behaviors so that BH gets disabled
- // on suspend and re-enabled on resume, but this might violate the principle of
- // least astonishment-- OTOH I hate seeing balloons when I to an app where I don't
- // need them.
- //
- // To use, just attach to a commander-- no muss, no fuss.
-
-
-
- #include "CBalloonKeyAttach.h"
- #include <PP_KeyCodes.h>
-
-
- CBalloonKeyAttachment::CBalloonKeyAttachment()
- : LAttachment(msg_KeyPress)
- {
- mBalloonState = ::HMGetBalloons();
- }
-
-
- // Default destructor doesn't do anything
- CBalloonKeyAttachment::~CBalloonKeyAttachment()
- {
- }
-
-
- void CBalloonKeyAttachment::ExecuteSelf(MessageT inMessage, // ignored
- void *ioParam)
- {
- Int16 theKey = ((EventRecord*)ioParam)->message & charCodeMask;
- mExecuteHost = true;
-
- // If it's the Help key, toggle the balloon state if the state we have
- // matches what we expect. If they don't match, it likely means that the user
- // toggled the state manually, so don't re-toggle it.
- if (char_Help == theKey)
- {
- if (::HMGetBalloons() == mBalloonState)
- {
- mBalloonState = !mBalloonState;
- ::HMSetBalloons(mBalloonState);
- mExecuteHost = false;
- }
- }
- }
-
-